# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>

_hkgname=timezone-series
pkgname=haskell-${_hkgname}
pkgver=0.1.13
pkgrel=1
pkgdesc='Enhanced timezone handling for Data.Time'
url='http://projects.haskell.org/time-ng/'
license=('BSD')
arch=('loong64' 'x86_64')
depends=('ghc-libs')
makedepends=('ghc')
source=(https://hackage.haskell.org/package/${_hkgname}-${pkgver}/${_hkgname}-${pkgver}.tar.gz)
sha256sums=('28efb715e3b7c25cbc13c468ab847d3a7b7bca0f5787b56bc1da53dee5e1c6a2')
sha512sums=('7e98bf1030f9df88d031f8fe28e56f50bd8e5da7615165324b5132a77aecc70da5906e2068afa43a819d711725c4c6cae8f6d17e7803f50b31038eb1634d4992')

build() {
  cd ${_hkgname}-${pkgver}
    runhaskell Setup configure -O \
      --enable-shared \
      --enable-executable-dynamic \
      --disable-library-vanilla \
      --prefix=/usr \
      --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname \
      --dynlibdir=/usr/lib \
      --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm \
      --ghc-option=-optl-Wl\,-z\,relro\,-z\,now \
      --ghc-option='-pie'
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup haddock
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

check() {
  cd ${_hkgname}-${pkgver}
  runhaskell Setup test --show-details=direct
}

package() {
  cd ${_hkgname}-${pkgver}
  install -Dm 744 register.sh "${pkgdir}/usr/share/haskell/register/${pkgname}.sh"
  install -Dm 744 unregister.sh "${pkgdir}/usr/share/haskell/unregister/${pkgname}.sh"
  install -dm 755 "${pkgdir}/usr/share/doc/ghc/html/libraries"
  runhaskell Setup copy --destdir="$pkgdir"

  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
  ln -s /usr/share/doc/${pkgname}/html "${pkgdir}/usr/share/doc/ghc/html/libraries/${_hkgname}"
}

# vim: ts=2 sw=2 et:
